<template>
    <!-- 施组方案联审-->
    <div class="schemeApproval">
      <a-spin :spinning="loading">
      <title-name title="施组方案联审" style="margin-top: 50px"></title-name>
      <div class="table-div">
        <h3 class="updateSummary-h3">当月施组方案联审情况</h3>
        <a-table  :columns="columns" bordered :pagination="false" :data-source="tableData"> </a-table>
      </div>
       </a-spin>
    </div>
  </template>
    <script>
  import { summaryMixin } from './mergeCell'
  import { queryMonthTechnicalProgramjointReviewList } from '@/api/technical/summary' // api
  export default {
    mixins: [summaryMixin], //混入文件
    name: 'a' + Date.now(),
    props: {
    monthTechnicalId: {
      type: String,
      default() {
        return ''
      }
    },
    orgTreeObj:{
      type:Object,
      default(){
        return {}
      }
    }
  },
    data() {
      this.columns = [
        {
          title: '所属分公司',
          align: 'center',
          dataIndex: 'branchCompany',
          width:'16%',
          customRender: (text, row, index) => {
          // this.$nextTick(() => {
          let rowSpan = 1
          if (index != 0 && text === this.tableData[index - 1].branchCompany) {
            rowSpan = 0
            // 若不是，则往下合并与改行考核内容一致行的总行数
          } else {
            rowSpan = [...this.tableData].filter((i) => i.branchCompany == text).length
          }
          return {
            children: text,
            attrs: {
              rowSpan: rowSpan,
            },
          }
          // })
        },
        },
        { title: '所属项目名称', align: 'center', dataIndex: 'projectName', width:'18%',
           customRender: (text, row, index) => {
              let rowSpan = 1
              if (
                  index != 0 &&
                  text === this.tableData[index - 1].projectName &&
                  row.branchCompany ===this.tableData[index - 1].branchCompany
              ) {
                  rowSpan = 0
                  // 若不是，则往下合并与改行考核内容一致行的总行数
              } else {
                  rowSpan = [...this.tableData].filter((i) => i.projectName == text && row.branchCompany === i.branchCompany).length
              }
              return {
                  children: text,
                  attrs: {
                  rowSpan: rowSpan,
                  },
              }
              // })
              },
      },
        { title: '会议名称', dataIndex: 'meetName', align: 'center', width:'13%',
          customRender: (text, row, index) => {
              let rowSpan = 1
              if (
                  index != 0 &&
                  text === this.tableData[index - 1].meetName &&
                  row.branchCompany ===this.tableData[index - 1].branchCompany &&  row.projectName ===this.tableData[index - 1].projectName
              ) {
                  rowSpan = 0
                  // 若不是，则往下合并与改行考核内容一致行的总行数
              } else {
                  rowSpan = [...this.tableData].filter((i) => i.meetName == text && row.branchCompany === i.branchCompany  && row.projectName === i.projectName).length
              }
              return {
                  children: text,
                  attrs: {
                  rowSpan: rowSpan,
                  },
              }
              // })
              },
      },
        { title: '主持人', dataIndex: 'hosUsertName', align: 'center',width:'11%'},
        { title: '会议时间', dataIndex: 'meetDate', align: 'center',width:'9%',},
        { title: '方案名称', dataIndex: 'programName', align: 'center',width:'11%',},
        { title: '方案类别', dataIndex: 'planTypeName', align: 'center',width:'11%',},
        { title: '主评专家', dataIndex: 'appraiseName', align: 'center',width:'11%',},
      ]
      return {
        loading:false,
        tableData:[],
      }
    },
    watch:{
    monthTechnicalId: {
      handler(val) {
        this.queryMonthTechnicalProgramjointReviewListFn(val,this.orgTreeObj);
      },
      immediate: true
    },
    orgTreeObj:{
      handler(newVal) {
        this.queryMonthTechnicalProgramjointReviewListFn(this.monthTechnicalId,newVal);
			},
			deep:true, // 深度监听
			//immediate:true, // 初始化监听
    }
  },
    methods: {
      queryMonthTechnicalProgramjointReviewListFn(id,searchQuery){
        let obj = {
        monthTechnicalId:id,
        searchQuery,
      }
      this.loading = true
      queryMonthTechnicalProgramjointReviewList(obj).then((res) => {
        this.loading = false
        if (res.code == '0') {
          this.tableData = res.data
        }
  
      })
    }
    },
    mounted() {
    }
  }
  </script>
    <style lang="less" scoped>
    @deep: ~'>>>';
  .schemeApproval{
   .updateSummary-h3{
          line-height: 45px;
          width: 100%;
          text-align: center;
          background: rgb(244, 244, 244);
          border: 1px solid gainsboro;
          border-bottom: none;
          font-size: 14px;
          margin: 0;
      }
    @{deep}.titleName{
      margin-top:10px!important;
    }
    .table-div{
      margin-bottom: 40px;
    }
  }
  </style>
    